import java.util.*;
/*Vector implements a dynamic array. It is similar to ArrayList, but with 
 * two differences:

Vector is synchronized.

Vector contains many legacy methods that are not part of the collections 
framework.

Vector proves to be very useful if you don't know the size of the array 
in advance, or you just need one that can change sizes over the lifetime of a program.
*/public class VectorCollection {
	
	public void vectorMethod() {
		// initial size is 3, increment is 2
	      Vector v = new Vector(3, 2);
	      
	      
	      System.out.println("Initial size: " + v.size());
	      System.out.println("Initial capacity: " +
	      v.capacity());
	      v.add(new Integer(111));
	      v.addElement(new Integer(1));
	      v.addElement(new Integer(2));
	      v.addElement(new Integer(3));
	      v.addElement(new Integer(4));
	      System.out.println("Capacity after four additions: " +
	          v.capacity());
	      
	      //ArrayList
	      ArrayList<Integer> listInt = new ArrayList<Integer>();
	      
	      System.out.println("Initial Size of ArrayList: "+listInt.size());
	      
	      listInt.add(new Integer(10));
	      listInt.add(new Integer(12));
	      listInt.add(new Integer(15));
	      listInt.add(new Integer(17));
	      listInt.add(new Integer(19));
	      
	      int[] str = new int[10];
	      
	      /*for(Integer al: listInt) {
	    	  System.out.println("Element "+al.intValue());
	      }*/
	      
	     Iterator its = listInt.iterator();
	     while(its.hasNext()) {
	    	 System.out.println("Element "+its.next());
	     
	     }
	      
	      
	      v.addElement(new Double(5.45));
	      System.out.println("Current capacity: " +
	      v.capacity());
	      v.addElement(new Double(6.08));
	      v.addElement(new Integer(7));
	      System.out.println("Current capacity: " +
	      v.capacity());
	      v.addElement(new Float(9.4));
	      v.addElement(new Integer(10));
	      System.out.println("Current capacity: " +
	      v.capacity());
	      v.addElement(new Integer(11));
	      v.addElement(new Integer(12));
	      System.out.println("First element: " +
	         (Integer)v.firstElement());
	      System.out.println("Last element: " +
	         (Integer)v.lastElement());
	      if(v.contains(new Integer(3)))
	         System.out.println("Vector contains 3.");
	      // enumerate the elements in the vector.
	      Enumeration vEnum = v.elements();
	      System.out.println("\nElements in vector:");
	      while(vEnum.hasMoreElements())
	         System.out.print(vEnum.nextElement() + " ");
	      System.out.println();
	   
	}
}
